Notes for Hispanic-Latinx heritage month

These are notes for Hispanic heritage month. https://www.hispanicheritagemonth.gov/ September 15 to October 15

library(devtools)
## Warning: package 'devtools' was built under R version 4.0.5
## Loading required package: usethis
## Warning: package 'usethis' was built under R version 4.0.5
library(sf)
## Warning: package 'sf' was built under R version 4.0.5
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.5
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(psrccensus)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.5
Sys.getenv("CENSUS_API_KEY")
## [1] "c4780eb03010d73b7ae4e6894c1592375e545a21"

I searched the api table list for Hispanic to see what data is available. https://api.census.gov/data/2019/acs/acs5/variables.html

How does Hispanic age breakdown compare to non-Hispanic? * Age is found in B1002I, B1002A

What Races do Hispanic people identify with? * B3002

What specific origins do people come from? * B300, B05003

What means of transportation do people use to get to work? * B06004, B06007 means of transportation to work for workplace geo

Information about grandparents living with grandchildren * B08105H; I grandparents B10051I

Are more Hispanic women giving birth than all women? * B13002 women who gave birth

What are the educational attainment levels for Hispanic people? * B15002 educational attainment

What are the poverty rates for Hispanic people? * B17001 B19001

Median Age by Hispanic and All

overall_age_df <- get_acs_recs(geography = 'county',
             table.names = c('B01002'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
hispanic_age_df<-get_acs_recs(geography = 'county',
             table.names = c('B01002I'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
overall_hispanic_df<-rbind(overall_age_df, hispanic_age_df)
age_df<-overall_hispanic_df%>% filter(label=='Estimate!!Median age --!!Total:' & name !='Region') %>% mutate('Hispanic'=ifelse(variable=='B01002_001', 'All Population', 'Hispanic or Latino Population'))
write.table(age_df,"clipboard", sep='\t', row.names=FALSE )

age_df
## # A tibble: 8 x 12
##   GEOID name             state      variable estimate   moe label concept census_geography
##   <chr> <chr>            <chr>      <chr>       <dbl> <dbl> <chr> <chr>   <chr>           
## 1 53033 King County      Washington B01002_~     36.9   0.2 Esti~ MEDIAN~ County          
## 2 53035 Kitsap County    Washington B01002_~     39.5   0.3 Esti~ MEDIAN~ County          
## 3 53053 Pierce County    Washington B01002_~     36.4   0.2 Esti~ MEDIAN~ County          
## 4 53061 Snohomish County Washington B01002_~     38.2   0.3 Esti~ MEDIAN~ County          
## 5 53033 King County      Washington B01002I~     28.5   0.4 Esti~ MEDIAN~ County          
## 6 53035 Kitsap County    Washington B01002I~     27.3   0.3 Esti~ MEDIAN~ County          
## 7 53053 Pierce County    Washington B01002I~     25.2   0.2 Esti~ MEDIAN~ County          
## 8 53061 Snohomish County Washington B01002I~     26.4   0.3 Esti~ MEDIAN~ County          
## # ... with 3 more variables: acs_type <chr>, year <dbl>, Hispanic <chr>
ggplot(data=age_df, aes(x=name, y=estimate, fill=Hispanic))+geom_bar(stat='identity', position=position_dodge())+
  geom_text(aes(label=estimate), vjust=1.6, color="white",
            position = position_dodge(0.9), size=3.5)

Hispanic Population by Tract

tract.big.tbl <- psrccensus::get_decennial_recs(geography='tract',table_codes=c('P005'),year=c(2010))
## Getting data from the 2010 decennial Census
## Loading SF1 variables for 2010 from table P005. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
## Using Census Summary File 1
## Getting data from the 2010 decennial Census
## Loading SF1 variables for 2010 from table P005. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
## Using Census Summary File 1
## Getting data from the 2010 decennial Census
## Loading SF1 variables for 2010 from table P005. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
## Using Census Summary File 1
## Getting data from the 2010 decennial Census
## Loading SF1 variables for 2010 from table P005. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
## Using Census Summary File 1
tract.tbl <- tract.big.tbl %>%
filter(label=='Total!!Hispanic or Latino')

gdb.nm <- paste0("MSSQL:server=",
"AWS-PROD-SQL\\Sockeye",
";database=",
"ElmerGeo",
";trusted_connection=yes")

spn <-  2285

tract_layer_name <- "dbo.tract2010_nowater"

tract.lyr <- st_read(gdb.nm, tract_layer_name, crs = spn)
## Reading layer `dbo.tract2010_nowater' from data source 
##   `MSSQL:server=AWS-PROD-SQL\Sockeye;database=ElmerGeo;trusted_connection=yes' 
##   using driver `MSSQLSpatial'
## Simple feature collection with 773 features and 19 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 1099353 ymin: -97548.53 xmax: 1622631 ymax: 477101.5
## Projected CRS: NAD83 / Washington North (ftUS)
m<-create_tract_map(tract.tbl=tract.tbl, tract.lyr=tract.lyr,  
                 legend.title='Hispanic Population', legend.subtitle='by Census Tract')

m

Women who gave birth

women_birth_df<-get_acs_recs(geography = 'county',
             table.names = c('B13002'),
             years=c(2019),
             acs.type = 'acs1') 
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
women_birth_df_hispanic<-get_acs_recs(geography = 'county',
             table.names = c('B13002I'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
women_birth_df
## # A tibble: 95 x 11
##    GEOID name        state      variable   estimate   moe label concept census_geography
##    <chr> <chr>       <chr>      <chr>         <dbl> <dbl> <chr> <chr>   <chr>           
##  1 53033 King County Washington B13002_001   576759  2190 Esti~ WOMEN ~ County          
##  2 53033 King County Washington B13002_002    27413  2965 Esti~ WOMEN ~ County          
##  3 53033 King County Washington B13002_003    23243  2931 Esti~ WOMEN ~ County          
##  4 53033 King County Washington B13002_004       42    69 Esti~ WOMEN ~ County          
##  5 53033 King County Washington B13002_005    14458  2394 Esti~ WOMEN ~ County          
##  6 53033 King County Washington B13002_006     8743  1484 Esti~ WOMEN ~ County          
##  7 53033 King County Washington B13002_007     4170  1499 Esti~ WOMEN ~ County          
##  8 53033 King County Washington B13002_008      382   528 Esti~ WOMEN ~ County          
##  9 53033 King County Washington B13002_009     2960  1053 Esti~ WOMEN ~ County          
## 10 53033 King County Washington B13002_010      828   631 Esti~ WOMEN ~ County          
## # ... with 85 more rows, and 2 more variables: acs_type <chr>, year <dbl>
women_birth_df_hispanic
## # A tibble: 35 x 11
##    GEOID name          state      variable    estimate   moe label concept census_geography
##    <chr> <chr>         <chr>      <chr>          <dbl> <dbl> <chr> <chr>   <chr>           
##  1 53033 King County   Washington B13002I_001    62809   637 Esti~ WOMEN ~ County          
##  2 53033 King County   Washington B13002I_002     2679   949 Esti~ WOMEN ~ County          
##  3 53033 King County   Washington B13002I_003     2272   918 Esti~ WOMEN ~ County          
##  4 53033 King County   Washington B13002I_004      407   341 Esti~ WOMEN ~ County          
##  5 53033 King County   Washington B13002I_005    60130  1196 Esti~ WOMEN ~ County          
##  6 53033 King County   Washington B13002I_006    25881  2306 Esti~ WOMEN ~ County          
##  7 53033 King County   Washington B13002I_007    34249  2352 Esti~ WOMEN ~ County          
##  8 53035 Kitsap County Washington B13002I_001     5837   406 Esti~ WOMEN ~ County          
##  9 53035 Kitsap County Washington B13002I_002      345   295 Esti~ WOMEN ~ County          
## 10 53035 Kitsap County Washington B13002I_003      228   251 Esti~ WOMEN ~ County          
## # ... with 25 more rows, and 2 more variables: acs_type <chr>, year <dbl>

1049422 women age 15 to 50 in the region

55604 gave birth (5.3%)

118645 Hispanic women

6694 (5.6%)

Poverty Rates

poverty_df_white <- get_acs_recs(geography = 'county',
             table.names = c('B17020H'),
             years=c(2019),
             acs.type = 'acs5')
## Getting data from the 2015-2019 5-year ACS
poverty_df_hispanic<- get_acs_recs(geography = 'county',
             table.names = c('B17020I'),
             years=c(2019),
             acs.type = 'acs5')
## Getting data from the 2015-2019 5-year ACS
poverty_df_white
## # A tibble: 85 x 11
##    GEOID name        state      variable    estimate   moe label concept census_geography
##    <chr> <chr>       <chr>      <chr>          <dbl> <dbl> <chr> <chr>   <chr>           
##  1 53033 King County Washington B17020H_001  1292995  1267 Esti~ POVERT~ County          
##  2 53033 King County Washington B17020H_002    81042  2514 Esti~ POVERT~ County          
##  3 53033 King County Washington B17020H_003     3260   489 Esti~ POVERT~ County          
##  4 53033 King County Washington B17020H_004     2898   339 Esti~ POVERT~ County          
##  5 53033 King County Washington B17020H_005     3507   486 Esti~ POVERT~ County          
##  6 53033 King County Washington B17020H_006    51922  1872 Esti~ POVERT~ County          
##  7 53033 King County Washington B17020H_007    12354   811 Esti~ POVERT~ County          
##  8 53033 King County Washington B17020H_008     4234   554 Esti~ POVERT~ County          
##  9 53033 King County Washington B17020H_009     2867   444 Esti~ POVERT~ County          
## 10 53033 King County Washington B17020H_010  1211953  2871 Esti~ POVERT~ County          
## # ... with 75 more rows, and 2 more variables: acs_type <chr>, year <dbl>
poverty_df_hispanic
## # A tibble: 85 x 11
##    GEOID name        state      variable    estimate   moe label concept census_geography
##    <chr> <chr>       <chr>      <chr>          <dbl> <dbl> <chr> <chr>   <chr>           
##  1 53033 King County Washington B17020I_001   209087   461 Esti~ POVERT~ County          
##  2 53033 King County Washington B17020I_002    30076  2556 Esti~ POVERT~ County          
##  3 53033 King County Washington B17020I_003     4527   673 Esti~ POVERT~ County          
##  4 53033 King County Washington B17020I_004     4567   712 Esti~ POVERT~ County          
##  5 53033 King County Washington B17020I_005     3488   581 Esti~ POVERT~ County          
##  6 53033 King County Washington B17020I_006    16134  1320 Esti~ POVERT~ County          
##  7 53033 King County Washington B17020I_007     1007   296 Esti~ POVERT~ County          
##  8 53033 King County Washington B17020I_008      291   122 Esti~ POVERT~ County          
##  9 53033 King County Washington B17020I_009       62    61 Esti~ POVERT~ County          
## 10 53033 King County Washington B17020I_010   179011  2629 Esti~ POVERT~ County          
## # ... with 75 more rows, and 2 more variables: acs_type <chr>, year <dbl>

Median Income

income_df_white <- get_acs_recs(geography = 'county',
             table.names = c('B19013H'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
income_df_hispanic<- get_acs_recs(geography = 'county',
             table.names = c('B19013I'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
white_hispanic_df<-merge(income_df_white, income_df_hispanic, by ='name')

white_hispanic_df
##               name GEOID.x    state.x  variable.x estimate.x    moe.x
## 1      King County   53033 Washington B19013H_001     109124 2900.000
## 2    Kitsap County   53035 Washington B19013H_001      81317 4099.000
## 3    Pierce County   53053 Washington B19013H_001      83992 2468.000
## 4           Region  REGION Washington B19013H_001     363379 6431.024
## 5 Snohomish County   53061 Washington B19013H_001      88946 3171.000
##                                                                                        label.x
## 1 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 2 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 3 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 4 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 5 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
##                                                                                                                              concept.x
## 1 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER)
## 2 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER)
## 3 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER)
## 4 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER)
## 5 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER)
##   census_geography.x acs_type.x year.x GEOID.y    state.y  variable.y
## 1             County       acs1   2019   53033 Washington B19013I_001
## 2             County       acs1   2019   53035 Washington B19013I_001
## 3             County       acs1   2019   53053 Washington B19013I_001
## 4             County       acs1   2019  REGION Washington B19013I_001
## 5             County       acs1   2019   53061 Washington B19013I_001
##   estimate.y    moe.y
## 1      78175  7656.00
## 2      66667 26481.00
## 3      67212  7294.00
## 4     286104 29580.61
## 5      74050  7871.00
##                                                                                        label.y
## 1 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 2 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 3 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 4 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
## 5 Estimate!!Median household income in the past 12 months (in 2019 inflation-adjusted dollars)
##                                                                                                             concept.y
## 1 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (HISPANIC OR LATINO HOUSEHOLDER)
## 2 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (HISPANIC OR LATINO HOUSEHOLDER)
## 3 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (HISPANIC OR LATINO HOUSEHOLDER)
## 4 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (HISPANIC OR LATINO HOUSEHOLDER)
## 5 MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (HISPANIC OR LATINO HOUSEHOLDER)
##   census_geography.y acs_type.y year.y
## 1             County       acs1   2019
## 2             County       acs1   2019
## 3             County       acs1   2019
## 4             County       acs1   2019
## 5             County       acs1   2019
write.table(white_hispanic_df,"clipboard", sep='\t', row.names=FALSE )

Means of Transportation to Work

white_transport_df <- get_acs_recs(geography = 'county',
             table.names = c('B08105A'),
             years=c(2019),
             acs.type = 'acs5')
## Getting data from the 2015-2019 5-year ACS
hispanic_transport_df <- get_acs_recs(geography = 'county',
             table.names = c('B08105I'),
             years=c(2019),
             acs.type = 'acs5')
## Getting data from the 2015-2019 5-year ACS
white_hispanic_df<-rbind(white_transport_df, hispanic_transport_df)%>%filter(name=='Region')



write.table(white_hispanic_df,"clipboard", sep='\t', row.names=FALSE )


white_hispanic_df
## # A tibble: 14 x 11
##    GEOID  name   state      variable    estimate   moe label concept census_geography
##    <chr>  <chr>  <chr>      <chr>          <dbl> <dbl> <chr> <chr>   <chr>           
##  1 REGION Region Washington B08105A_001  1508149 5040. Esti~ MEANS ~ County          
##  2 REGION Region Washington B08105A_002  1047108 6154. Esti~ MEANS ~ County          
##  3 REGION Region Washington B08105A_003   125851 2867. Esti~ MEANS ~ County          
##  4 REGION Region Washington B08105A_004   132724 2411. Esti~ MEANS ~ County          
##  5 REGION Region Washington B08105A_005    58884 1938. Esti~ MEANS ~ County          
##  6 REGION Region Washington B08105A_006    37356 1374. Esti~ MEANS ~ County          
##  7 REGION Region Washington B08105A_007   106226 2501. Esti~ MEANS ~ County          
##  8 REGION Region Washington B08105I_001   194800 1818. Esti~ MEANS ~ County          
##  9 REGION Region Washington B08105I_002   128135 1991. Esti~ MEANS ~ County          
## 10 REGION Region Washington B08105I_003    29012 1499. Esti~ MEANS ~ County          
## 11 REGION Region Washington B08105I_004    19386 1217. Esti~ MEANS ~ County          
## 12 REGION Region Washington B08105I_005     7749  700. Esti~ MEANS ~ County          
## 13 REGION Region Washington B08105I_006     3371  504. Esti~ MEANS ~ County          
## 14 REGION Region Washington B08105I_007     7147  665. Esti~ MEANS ~ County          
## # ... with 2 more variables: acs_type <chr>, year <dbl>

Country of Origin

country_df_hispanic<- get_acs_recs(geography = 'county',
             table.names = c('B03001'),
             years=c(2019),
             acs.type = 'acs1')
## The 1-year ACS provides data for geographies with populations of 65,000 and greater.
## Getting data from the 2019 1-year ACS
country_df_hispanic
## # A tibble: 155 x 11
##    GEOID name        state      variable   estimate   moe label concept census_geography
##    <chr> <chr>       <chr>      <chr>         <dbl> <dbl> <chr> <chr>   <chr>           
##  1 53033 King County Washington B03001_001  2252782    NA Esti~ HISPAN~ County          
##  2 53033 King County Washington B03001_002  2030140    NA Esti~ HISPAN~ County          
##  3 53033 King County Washington B03001_003   222642    NA Esti~ HISPAN~ County          
##  4 53033 King County Washington B03001_004   159516  7614 Esti~ HISPAN~ County          
##  5 53033 King County Washington B03001_005     9798  2693 Esti~ HISPAN~ County          
##  6 53033 King County Washington B03001_006     4339  1426 Esti~ HISPAN~ County          
##  7 53033 King County Washington B03001_007     1521   996 Esti~ HISPAN~ County          
##  8 53033 King County Washington B03001_008    21608  5056 Esti~ HISPAN~ County          
##  9 53033 King County Washington B03001_009      947   570 Esti~ HISPAN~ County          
## 10 53033 King County Washington B03001_010     4903  1718 Esti~ HISPAN~ County          
## # ... with 145 more rows, and 2 more variables: acs_type <chr>, year <dbl>